<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>加载中...</title>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
	
	init();
	function init(){
		var partner = getQueryVariable("partner");
		var userid = getQueryVariable("userid");
		var time = getQueryVariable("time");
		var sign = getQueryVariable("sign");
		var token = localStorage.getItem("token");
		
		if(partner==null || partner==''){
			alert("partner不可为空");
			return;
		}
		if(userid==null || userid==''){
			alert("userid不可为空");
			return;
		}
		if(time==null || time==''){
			alert("time不可为空");
			return;
		}
		if(sign==null || sign==''){
			alert("sign不可为空");
			return;
		}
		
		var params = {
				"partner":partner, 
				"userid":userid, 
				"time":time, 
				"sign":sign,
				"token":token};
		var url = "../api/integrating";
		$.post(url, params, function(data){
			//alert(JSON.stringify(data));
			if(data.retCode){
				var json = data.result;
				localStorage.setItem("token", json.token);
				localStorage.setItem("skin", json.skin);
				//localStorage.setItem("name", json.name);
				//localStorage.setItem("logo_pic", json.pic);
				sessionStorage.clear();
				location.href = "index.html";
			}
		});
		
	}

	function getQueryVariable(variable) {
		var query = window.location.search.substring(1);
		var vars = query.split("&");
		for (var i = 0; i < vars.length; i++) {
			var pair = vars[i].split("=");
			if (pair[0] == variable) {
				return pair[1];
			}
		}
		return (false);
	}
</script>
</body>
</html>